package net.rlair.sbdemo.dao.jpa.converter;

import net.rlair.sbdemo.constant.SexEnum;

import javax.persistence.AttributeConverter;

public class SexConverter implements AttributeConverter<SexEnum, Integer> {
    @Override
    public Integer convertToDatabaseColumn(final SexEnum sexEnum) {
        return sexEnum == null ? null : sexEnum.getValue();
    }

    @Override
    public SexEnum convertToEntityAttribute(final Integer integer) {
        return SexEnum.value2Enum(integer);
    }
}
